package aod.android.com.bernay.fixing.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import aod.android.com.bernay.R;

public class FixingOpenAdapter extends BaseAdapter {
    private Context context;
    private Integer [] imgs;
    private String [] strings= {
            "开启设备",
            "关闭设备",
            "录制视频",
            "视频调取",
            "实时对讲",
            "车外监听",
            "截图",
            "行驶轨迹",
            "当前位置"
    };
    public FixingOpenAdapter(Context context,Integer [] imgs) {
        this.context = context;
        this.imgs = imgs;
    }
    @Override
    public int getCount() {
        return imgs.length;
    }

    @Override
    public Object getItem(int position) {
        return imgs[position];
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = View.inflate(context, R.layout.fixing_gridview_item, null);
            holder = new ViewHolder();
            convertView.setTag(holder);
            holder.fixing_tv = convertView.findViewById(R.id.fixing_tv);
            holder.fixing_iv = convertView.findViewById(R.id.fixing_iv);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.fixing_tv.setText(strings[position]);
        holder.fixing_iv.setBackgroundResource(imgs[position]);
        return convertView;
    }
    static class ViewHolder {
        TextView fixing_tv;
        ImageView fixing_iv;
    }


}
